﻿using Microsoft.AspNetCore.Mvc;
using My.Admin.Dto.System;
using My.Admin.Model.System;
using My.Admin.Model;
using My.Core.DynamicWebApi.Attributes;
using My.Admin.Service.System.IService;
using Microsoft.AspNetCore.Authorization;

namespace My.Admin.Dynamic
{
	[Service("SysDictDataController")]
	public class SysDictDataController
	{
		private readonly ISysDictDataService _SysDictDataService;
		public SysDictDataController(ISysDictDataService SysDictDataService)
		{
			_SysDictDataService = SysDictDataService;
		}

		/// <summary>
		/// 获取字典值分页列表
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task<PagedInfo<SysDictData>> Page(PageDictDataInput input)
		{
			return await _SysDictDataService.Page(input);
		}

		/// <summary>
		/// 获取字典值列表
		/// </summary>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<List<SysDictData>> GetList([FromQuery] GetDataDictDataInput input)
		{
			return await _SysDictDataService.GetList(input);
		}

		/// <summary>
		/// 增加字典值
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task AddDictData(AddDictDataInput input)
		{
			await _SysDictDataService.AddDictData(input);
		}

		/// <summary>
		/// 更新字典值
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task UpdateDictData(UpdateDictDataInput input)
		{
			await _SysDictDataService.UpdateDictData(input);
		}

		/// <summary>
		/// 删除字典值
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task DeleteDictData(DeleteDictDataInput input)
		{
			await _SysDictDataService.DeleteDictData(input);
		}

		/// <summary>
		/// 获取字典值详情
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<SysDictData> GetDetail([FromQuery] DictDataInput input)
		{
			return await _SysDictDataService.GetDetail(input);
		}

		/// <summary>
		/// 修改字典值状态
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task SetStatus(DictDataInput input)
		{
			await _SysDictDataService.SetStatus(input);
		}

		/// <summary>
		/// 根据字典类型编码获取字典值集合
		/// </summary>
		/// <param name="code"></param>
		/// <returns></returns>
		[Authorize]
		[HttpGet("{code}")]
		public async Task<List<SysDictData>> GetDataList(string code)
		{
			return await _SysDictDataService.GetDataList(code);
		}

		/// <summary>
		/// 根据查询条件获取字典值集合
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<List<SysDictData>> GetDataList([FromQuery] QueryDictDataInput input)
		{
			return await _SysDictDataService.GetDataList(input);
		}
	}
}
